//
// Created by aaa on 2025/7/10.
//


#include<bits/stdc++.h>

using namespace std;
const int N = 2010;

char a[N],b[N];
int dp[N][N];

//编辑距离
//sfdqxbw
//gfdgw
int main(){
    cin >> (a+1);
    cin >> (b+1);

    int n = strlen(a+1);
    int m = strlen(b+1);

    for(int i = 1;i <= n;i++) dp[i][0] = i;
    for(int i = 1;i <= m;i++) dp[0][i] = i;


    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            if(a[i] == b[j]) dp[i][j] = dp[i-1][j-1];
            else dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1])) + 1;
        }
    }

    cout << dp[n][m];

//    for(int i = 0;i <= n;i++){
//        for(int j = 0;j <= m;j++){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }

    return 0;
}